package client;


import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;


public class MainClient {
	public static void main (String args[]){
		if(args.length != 1) {
			System.out.println("Usage <addresseIP> (without the port number)");
			return;
		}
		if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
		}
		IClient clnt = null;
		try {
			String serverLocation = args[0];
			clnt = new Client(serverLocation);
			ConsoleClient console = new ConsoleClient(clnt);
			while(console.logOn() != 0);
			Client myClient = (Client) clnt;
		//	Naming.rebind("rmi://" + serverLocation + "/" + myClient.getUsername(), clnt);
			console.run();
		} catch (RemoteException e) {
			System.out.println("Error initialization client");
			System.out.println("Usage <addresseIP> (without the port number)");
			e.printStackTrace();
		} /*catch (MalformedURLException e) {
			e.printStackTrace();
			System.out.println("Usage <addresseIP> (without the port number)");
		}*/
	}
}
